Rewrite for robots.txt and favicon.ico [closed]
Posted
by
BHare
on Server Fault
See other posts from Server Fault
or by BHare
Published on 2011-02-17T23:50:15Z
Indexed on
2011/02/20
23:26 UTC
Read the original article
Hit count: 274
apache
|mod-rewrite
I have setup some rules in which subdomains (my users) will default to where I have located the robots.txt, favicon.ico, and crossdomain.xml
therefore if a user creates a site say
testing.mywebsite.com
and they don't make their own favicon.ico at testing.mywebsite.com/favicon.ico
, then it will use the favicon.ico I have in /misc/favicon.ico
This works perfect, but it doesn't work for the main website. If you attempt to go to
mywebsite.com/favicon.ico
it will check if "/" exists, in which it does. And then never redirects to /misc/favicon.ico
How can I get it so both instances redirect to /misc/favicon.ico
?
# Set all crossdomain (openpalace file) favorite icons and robots.txt doesnt exist on their
# side, then redirect to site's just to have something to go on.
RewriteCond %{REQUEST_URI} crossdomain.xml$
RewriteCond ^(.+)crossdomain.xml !-f
RewriteRule ^(.*)$ /misc/crossdomain.xml [L]
RewriteCond %{REQUEST_URI} favicon.ico$
RewriteCond ^(.+)favicon.ico !-f
RewriteRule ^(.*)$ /misc/favicon.ico [L]
RewriteCond %{REQUEST_URI} robots.txt$
RewriteCond ^(.+)robots.txt !-f
RewriteRule ^(.*)$ /misc/robots.txt [L]
© Server Fault or respective owner